<?php
include_once( "include/global.php" );
include_once( "include/process_db.php" );

header('Cache-Control: no-cache, must-revalidate');
header('Content-type: application/json');

// the data array to return
$ret = array();
$ret["status"] = "fail";
$ret["error_msg"] = "";

// open database
OpenDB();

// query
$user_list = QueryRecordData("users", "Name='" . $_GET["name"] . "' AND Password='" . $_GET["password"] . "'");
if( count($user_list) <= 0 )
{
	$ret["status"] = "fail";
	$ret["error_msg"] = "Invalid name & password.";
}
else
{
	$_SESSION["user_id"] = $user_list[0]["AutoID"];
	$ret["status"] = "success";
}

// close database
CloseDB();

// return data
echo json_encode( $ret );
?>
